package com.wen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wen.pojo.GatherDetails;
import com.wen.pojo.dto.GatherDetailsDto;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

public interface GatherDetailsMapper extends BaseMapper<GatherDetails> {

    @Select("SELECT gd.*,p.`picture`,p.name,s.company_name FROM  `gather` g,`gather_details` gd,`product` p,`supplier` s WHERE gd.gather_id=g.gather_id AND gd.product_id=p.`id` AND gd.supplier_id=s.supplier_id AND g.gather_order_number=#{id}")
    List<GatherDetailsDto> GatherDetailsById(String id);


    @Update("UPDATE `stock_details` SET `real_amount` = `real_amount` -  #{amount} WHERE `product_id`=#{id}\n")
    int updateAmount(@Param("amount") String amount, @Param("id") String id);




}
